/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/** *****************************************************************************************************
 *  \file     McuExt.h                                                                              *
 *  \brief    This file contains interface header for MCU MCAL driver, ...                              *
 *                                                                                                      *
 * <table>                                                                                              *
 * <tr><th>Date           <th>Version                                                                   *
 * <tr><td>2023/08/02     <td>1.0.0                                                                     *
 * </table>                                                                                             *
 *******************************************************************************************************/

#ifndef MCU_EXTEND_H
#define MCU_EXTEND_H

/********************************************************************************************************
 *                                      Include header files                                            *
 *******************************************************************************************************/
#include "Platform_Types.h"
#include "Std_Types.h"
#include "McuExt_Cfg.h"
#if (MCUEXT_PVT_SENSOR_ENABLE == STD_ON)
#include "McuExt_PvtSens.h"
#endif /** #if (MCUEXT_PVT_SENSOR_ENABLE == STD_ON) */
#if ((MCUEXT_VOLTAGE_SF_DETECTION_ENABLE == STD_ON) || (MCUEXT_VOLTAGE_LP_DETECTION_ENABLE == STD_ON))
#include "Vd.h"
#endif /** #if ((MCUEXT_VOLTAGE_SF_DETECTION_ENABLE == STD_ON) || (MCUEXT_VOLTAGE_LP_DETECTION_ENABLE == STD_ON)) */
#include "Mcal.h"

#if (MCUEXT_PVT_SENSOR_ENABLE == STD_ON)
extern const McuExt_PvtAlarmConfigType McuExt_PvtAlarmConfigTable[PVT_CHANNEL_NUMBER];
#endif /** #if (MCUEXT_PVT_SENSOR_ENABLE == STD_ON) */

#if ((MCUEXT_VOLTAGE_SF_DETECTION_ENABLE == STD_ON) || (MCUEXT_VOLTAGE_LP_DETECTION_ENABLE == STD_ON))
extern const McuExt_VdCfgType Mcu_VdConfigTable[VD_NUM];
#endif /** #if ((MCUEXT_VOLTAGE_SF_DETECTION_ENABLE == STD_ON) || (MCUEXT_VOLTAGE_LP_DETECTION_ENABLE == STD_ON)) */
/********************************************************************************************************
 *                                  Global Function Declarations                                        *
 *******************************************************************************************************/
#if (MCUEXT_PVT_SENSOR_ENABLE == STD_ON)
/** *****************************************************************************************************
 * \brief This function enable temperature monitor.
 *
 * \verbatim
 * Syntax             : void McuExt_PvtInit(const McuExt_PvtAlarmConfigType *configPtr)
 *
 * Service ID[hex]    : 0xA
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *
 * Description        : This function enable temperature monitor.
 * \endverbatim
 * Traceability       : SWSR_MCU_051 SW_SM001
 *******************************************************************************************************/
void McuExt_PvtInit(const McuExt_PvtAlarmConfigType *configPtr);
/** *****************************************************************************************************
 * \brief This function get temperature value.
 *
 * \verbatim
 * Syntax             : Std_ReturnType McuExt_PvtGet(float32 *temperaturePtr)
 *
 * Service ID[hex]    : 0xA
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : devPtr - pointer to pvt device
 *
 * Parameters (inout) : temperaturePtr - pointer to pvt value
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *
 * Description        : This function get temperature value.
 *                      Temperature value is not ready until 280ms after McuExt_PvtInit() is called.
 * \endverbatim
 * Traceability       : SWSR_MCU_051 SW_SM001
 *******************************************************************************************************/
Std_ReturnType McuExt_PvtGet(float32 *temperaturePtr);

/** *****************************************************************************************************
 * \brief This function deinit pvt for disable all alarm in all channel.
 *
 * \verbatim
 * Syntax             : Std_ReturnType McuExt_PvtDeinit(void)
 *
 * Service ID[hex]    : 0x34
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : devPtr - pointer to pvt device
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *                      E_OK for success and others for failure.
 *
 * Description        : This function deinit pvt for disable all alarm in all channel.
 *                      temperature can get.
 * \endverbatim
 * Traceability       : SWSR_MCU_051 SW_SM001
 *******************************************************************************************************/
Std_ReturnType McuExt_PvtDeinit(void);

/** *****************************************************************************************************
 * \brief This function stop pvt.
 *
 * \verbatim
 * Syntax             : Std_ReturnType McuExt_PvtStop(void)
 *
 * Service ID[hex]    : 0x35
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : devPtr - pointer to pvt device
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *                      E_OK for success and others for failure.
 *
 * Description        : This function stop pvt.temperature can not get.
 * \endverbatim
 * Traceability       : SWSR_MCU_051 SW_SM001
 *******************************************************************************************************/
Std_ReturnType McuExt_PvtStop(void);

/** *****************************************************************************************************
 * \brief This function clear alarm status according to channel and alarm type for pvt.
 *
 * \verbatim
 * Syntax             : Std_ReturnType McuExt_PvtClearStatus(McuExt_PvtChannelIdType channel,
                                     McuExt_PvtAlarmType alarm)
 *
 * Service ID[hex]    : 0x36
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : devPtr - pointer to pvt device
 *                      channel - channel id
 *                      alarm - alarm type
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *                      E_OK for success and others for failure.
 *
 * Description        : This function clear alarm status according to channel and alarm type for pvt.
 * \endverbatim
 * Traceability       : SWSR_MCU_051 SW_SM001
 *******************************************************************************************************/
Std_ReturnType McuExt_PvtClearStatus(McuExt_PvtChannelIdType channel,
                                     McuExt_PvtAlarmType alarm);

/** *****************************************************************************************************
 * \brief This function clear alarm status according to channel and alarm type for pvt.
 *
 * \verbatim
 * Syntax             : void McuExt_PvtEnableDisableAlarm(McuExt_PvtChannelIdType channel,
                                     McuExt_PvtAlarmType alarm, boolean enable);
 *
 * Service ID[hex]    : 0x05U
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : channel - channel id
 *                      alarm - alarm type
 *                      enable - TRUE:ON,FALSE:OFF
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *                      E_OK for success and others for failure.
 *
 * Description        : This function clear alarm status according to channel and alarm type for pvt.
 * \endverbatim
 * Traceability       : SWSR_MCU_051 SW_SM001
 *******************************************************************************************************/
void McuExt_PvtEnableDisableAlarm(McuExt_PvtChannelIdType channel,
                                     McuExt_PvtAlarmType alarm, boolean enable);

/** *****************************************************************************************************
 * \brief This function clear alarm status according to channel and alarm type for pvt.
 *
 * \verbatim
 * Syntax             : boolean McuExt_PvtGetStatus(McuExt_PvtChannelIdType channel, McuExt_PvtAlarmType alarm)
 *
 * Service ID[hex]    : 0x36
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : devPtr - pointer to pvt device
 *                      channel - channel id
 *                      alarm - alarm type
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *                      E_OK for success and others for failure.
 *
 * Description        : This function clear alarm status according to channel and alarm type for pvt.
 * \endverbatim
 *******************************************************************************************************/
boolean McuExt_PvtGetStatus(McuExt_PvtChannelIdType channel,
                                     McuExt_PvtAlarmType alarm);

/** *****************************************************************************************************
 * \brief Pvt channel0 irq handler.
 *
 * \verbatim
 * Syntax             : void McuExt_PvtChannel0IrqHandler(void)
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : Pvt channel1 irq handler.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
ISR(McuExt_PvtChannel0IrqHandler);

/** *****************************************************************************************************
 * \brief Pvt channel1 irq handler.
 *
 * \verbatim
 * Syntax             : void McuExt_PvtChannel1IrqHandler(void)
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : Pvt channel1 irq handler.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
ISR(McuExt_PvtChannel1IrqHandler);
#endif /** #if (MCUEXT_PVT_SENSOR_ENABLE == STD_ON) */

#if ((MCUEXT_VOLTAGE_SF_DETECTION_ENABLE == STD_ON) || (MCUEXT_VOLTAGE_LP_DETECTION_ENABLE == STD_ON))
/** *****************************************************************************************************
 * \brief This function service to initialize voltage detector.
 *
 * \verbatim
 * Syntax             : void McuExt_VdInit(const McuExt_VdCfgType *configPtr)
 *
 * Service ID[hex]    : 0xA
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *
 * Description        : This function service to initialize voltage detector.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
void McuExt_VdInit(const McuExt_VdCfgType *configPtr);
/** *****************************************************************************************************
 * \brief This function service to initialize voltage detector.
 *
 * \verbatim
 * Syntax             : uint32 McuExt_VdGetInterruptStatus(McuExt_VdIdType controllerId)
 *
 * Service ID[hex]    : 0xA
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *
 * Description        : This function service to initialize voltage detector.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
uint32 McuExt_VdGetInterruptStatus(McuExt_VdIdType controllerId);
/** *****************************************************************************************************
 * \brief This function service to initialize voltage detector.
 *
 * \verbatim
 * Syntax             : uint32 McuExt_VdGetDynamicStatus(McuExt_VdIdType controllerId)
 *
 * Service ID[hex]    : 0xA
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *
 * Description        : This function service to initialize voltage detector.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
uint32 McuExt_VdGetDynamicStatus(McuExt_VdIdType controllerId);
/** *****************************************************************************************************
 * \brief This function service to initialize voltage detector.
 *
 * \verbatim
 * Syntax             : void McuExt_VdClearInterruptStatus(McuExt_VdIdType controllerId)
 *
 * Service ID[hex]    : 0xA
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Non reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : errorId
 *
 * Description        : This function service to initialize voltage detector.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
void McuExt_VdClearInterruptStatus(McuExt_VdIdType controllerId);

/** **************************************************************************************
 * \brief This function is service to handle vd interrupt.

 * \verbatim
 * Syntax             : void McuExt_VdSFIrqHandler(void)

 * Service ID[hex]    : 0x00

 * Sync/Async         : Synchronous

 * Reentrancy         : Non reentrant

 * Parameters (in)    : None

 * Parameters (inout) : None

 * Parameters (out)   : None

 * Return value       : None

 * Description        : This function is service to handle vd interrupt.
 *

 * \endverbatim
 * Traceability       :
 *****************************************************************************************/
ISR(McuExt_VdSFIrqHandler);

/** *****************************************************************************************************
 * \brief VD irq handler.
 *
 * \verbatim
 * Syntax             : void McuExt_VdLPIrqHandler(void)
 *
 * Service ID[hex]    : None
 *
 * Sync/Async         : Synchronous
 *
 * Reentrancy         : Reentrant
 *
 * Parameters (in)    : None
 *
 * Parameters (inout) : None
 *
 * Parameters (out)   : None
 *
 * Return value       : None
 *
 * Description        : VD irq handler.
 * \endverbatim
 * Traceability       :
 *******************************************************************************************************/
ISR(McuExt_VdLPIrqHandler);

#endif /** #if ((MCUEXT_VOLTAGE_SF_DETECTION_ENABLE == STD_ON) || (MCUEXT_VOLTAGE_LP_DETECTION_ENABLE == STD_ON)) */
#endif /* MCU_EXTEND_H */
/* End of file */
